package net.mcreator.toolsasfood.procedures;

import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.Vec2;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.item.ItemStack;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.core.BlockPos;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.CommandSource;

public class GlowingProcedure {
	public static void execute(LevelAccessor world, double x, double y, double z) {
		if (world instanceof ServerLevel _level)
			_level.getServer().getCommands().performCommand(
					new CommandSourceStack(CommandSource.NULL, new Vec3(x, y, z), Vec2.ZERO, _level, 4, "", new TextComponent(""), _level.getServer(),
							null).withSuppressedOutput(),
					("summon tools_as_food:note_tap " + (x + 0.5) + " " + y + " " + (z + 0.5) + " "
							+ "{Glowing:true,Invulnerable:true,NoGravity:true,OnGround:false}"));
		if (world instanceof ServerLevel _level)
			_level.getServer().getCommands().performCommand(
					new CommandSourceStack(CommandSource.NULL, new Vec3((x + 0.5), y, (z + 0.5)), Vec2.ZERO, _level, 4, "", new TextComponent(""),
							_level.getServer(), null).withSuppressedOutput(),
					("execute as @e[type=tools_as_food:note_tap,distance=..0,limit=1] run team join"
							+ (("" + new ItemStack((world.getBlockState(new BlockPos((int) x, (int) y, (int) z))).getBlock())).replace("1 ", " "))
									.replace("deepslate_", "")));
	}
}
